package com.androidx.p013lv.mine.activity;

import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.viewpager.widget.ViewPager;
import com.androidx.p013lv.base.p015ui.BaseActivity;
import com.androidx.p013lv.mine.C1207R;
import com.androidx.p013lv.mine.databinding.ActivityMineCollectVideoLayoutBinding;
import com.androidx.p013lv.mine.fragment.CollectFragment;
import com.androidx.p013lv.mine.fragment.SmallVideoFragment;
import com.androidx.p013lv.mine.model.MineCollectModel;
import com.androidx.p013lv.mine.novel.fragment.MineCollectNovelFragment;
import com.google.android.material.tabs.TabLayout;
import com.gyf.immersionbar.ImmersionBar;
import p000a.shuyu.p005a.GSYVideoManager;

/* renamed from: com.androidx.lv.mine.activity.MineCollectVideoActivity */
public class MineCollectVideoActivity extends BaseActivity<ActivityMineCollectVideoLayoutBinding> {
    private boolean isEdit;
    private MineCollectModel model;

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(((ActivityMineCollectVideoLayoutBinding) this.binding).toolbar).statusBarDarkFont(false).init();
    }

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public int setLayout() {
        return C1207R.C1212layout.activity_mine_collect_video_layout;
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initView() {
        super.initView();
        this.model = (MineCollectModel) new ViewModelProvider(this).get(MineCollectModel.class);
        ((ActivityMineCollectVideoLayoutBinding) this.binding).setClick(new OnClick());
        ((ActivityMineCollectVideoLayoutBinding) this.binding).viewPager.setAdapter(new Adapter(getSupportFragmentManager()));
        ((ActivityMineCollectVideoLayoutBinding) this.binding).tabLayout.addOnTabSelectedListener((TabLayout.OnTabSelectedListener) new TabLayout.OnTabSelectedListener() {
            /* class com.androidx.p013lv.mine.activity.MineCollectVideoActivity.C12491 */

            @Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
            public void onTabReselected(TabLayout.Tab tab) {
            }

            @Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
            public void onTabSelected(TabLayout.Tab tab) {
                MineCollectVideoActivity.this.changeTabTextView(tab, true);
            }

            @Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
            public void onTabUnselected(TabLayout.Tab tab) {
                MineCollectVideoActivity.this.changeTabTextView(tab, false);
            }
        });
        ((ActivityMineCollectVideoLayoutBinding) this.binding).viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            /* class com.androidx.p013lv.mine.activity.MineCollectVideoActivity.C12502 */

            @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
            public void onPageScrollStateChanged(int i) {
            }

            @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
            public void onPageScrolled(int i, float f, int i2) {
            }

            @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
            public void onPageSelected(int i) {
                ((ActivityMineCollectVideoLayoutBinding) MineCollectVideoActivity.this.binding).setPosition(Integer.valueOf(i));
            }
        });
        ((ActivityMineCollectVideoLayoutBinding) this.binding).tabLayout.setupWithViewPager(((ActivityMineCollectVideoLayoutBinding) this.binding).viewPager);
        ((ActivityMineCollectVideoLayoutBinding) this.binding).viewPager.setNoScroll(true);
        this.model.getActionLive().observe(this, new Observer<Boolean>() {
            /* class com.androidx.p013lv.mine.activity.MineCollectVideoActivity.C12513 */

            public void onChanged(Boolean bool) {
                MineCollectVideoActivity.this.isEdit = bool.booleanValue();
                ((ActivityMineCollectVideoLayoutBinding) MineCollectVideoActivity.this.binding).setIsEdit(Boolean.valueOf(MineCollectVideoActivity.this.isEdit));
            }
        });
    }

    public void changeTabTextView(TabLayout.Tab tab, boolean z) {
        if (tab.getCustomView() == null) {
            tab.setCustomView(C1207R.C1212layout.attention_tab_layout_text);
        }
        TextView textView = (TextView) tab.getCustomView().findViewById(16908308);
        if (z) {
            textView.setTextAppearance(getActivity(), C1207R.C1214style.TabLayoutCollectTextSize);
        } else {
            textView.setTextAppearance(getActivity(), C1207R.C1214style.TabLayoutCollectNormalTextSize);
        }
    }

    @Override // androidx.activity.ComponentActivity, com.androidx.p013lv.base.p015ui.BaseActivity
    public void onBackPressed() {
        if (GSYVideoManager.isFullState(this)) {
            GSYVideoManager.backFromWindowFull(getActivity());
        } else {
            super.onBackPressed();
        }
    }

    /* renamed from: com.androidx.lv.mine.activity.MineCollectVideoActivity$Adapter */
    public static class Adapter extends FragmentStatePagerAdapter {
        @Override // androidx.viewpager.widget.PagerAdapter
        public int getCount() {
            return 3;
        }

        @Override // androidx.viewpager.widget.PagerAdapter
        public CharSequence getPageTitle(int i) {
            return i == 0 ? "視頻" : i == 1 ? "小視頻" : "小說";
        }

        Adapter(FragmentManager fragmentManager) {
            super(fragmentManager, 1);
        }

        @Override // androidx.fragment.app.FragmentStatePagerAdapter
        public Fragment getItem(int i) {
            if (i == 0) {
                return CollectFragment.newInstance();
            }
            if (i == 1) {
                return SmallVideoFragment.newInstance(2);
            }
            return MineCollectNovelFragment.newInstance();
        }
    }

    /* access modifiers changed from: protected */
    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.androidx.p013lv.base.p015ui.BaseActivity
    public void onDestroy() {
        super.onDestroy();
    }

    /* renamed from: com.androidx.lv.mine.activity.MineCollectVideoActivity$OnClick */
    public class OnClick {
        public OnClick() {
        }

        public void btnBack() {
            MineCollectVideoActivity.this.finish();
        }

        public void editCollect() {
            MineCollectVideoActivity mineCollectVideoActivity = MineCollectVideoActivity.this;
            mineCollectVideoActivity.isEdit = !mineCollectVideoActivity.isEdit;
            ((ActivityMineCollectVideoLayoutBinding) MineCollectVideoActivity.this.binding).setIsEdit(Boolean.valueOf(MineCollectVideoActivity.this.isEdit));
            MineCollectVideoActivity.this.model.setActionLive(MineCollectVideoActivity.this.isEdit);
        }
    }
}
